#include <linux/module.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>

#ifdef CONFIG_SMP
#define	__SMP__
#endif

#define	DATA_MAJOR 121

int cdata_open(struct inode *inode,struct file *fs)
{
	printk("CDATA open\n");
	return 0;
}

int cdata_close(struct inode *inode,struct file *fs)
{
	printk(KERN_ALERT "CDATA close\n");
	return 0;
}

ssize_t cdata_write(struct file *fs, const char *str, size_t size, loff_t *funLoff)
{
	printk(KERN_ALERT "IN WRITE\n");
	printk(KERN_ALERT "POINT = %p\n",&funLoff);
	return sizeof(str);
}

static struct file_operations cdata_fops={
	open:		cdata_open,
	release:	cdata_close,
	write:		cdata_write,
};

int my_init_module(void)
{
	if(register_chrdev(DATA_MAJOR,"cdata",&cdata_fops)){
		printk(KERN_ALERT "Register dev Fail\n");
		return -1;
	}

	printk(KERN_ALERT "Hello driver\n");
	return 0;
}

void my_cleanup_module(void)
{
	unregister_chrdev(DATA_MAJOR,"cdata");

	printk(KERN_ALERT "Bye Bye\n");
	return;
}

module_init(my_init_module);
module_exit(my_cleanup_module);

MODULE_LICENSE("GPL");
